package com.zs.toolbox.web2j.system.core.controller.client;


import com.zs.toolbox.web2j.common.request.WtPrimaryKeyReqeust;
import com.zs.toolbox.web2j.common.response.WtBaseResponse;
import com.zs.toolbox.web2j.common.web.WtBaseController;
import com.zs.toolbox.web2j.system.core.entity.WtDictionaryItemEntity;
import com.zs.toolbox.web2j.system.core.entity.WtUserEntity;
import com.zs.toolbox.web2j.system.core.request.WtDictListReqeust;
import com.zs.toolbox.web2j.system.core.service.WtCoreClientService;
import com.zs.toolbox.web2j.system.core.service.WtDictionaryItemService;
import com.zs.toolbox.web2j.system.core.service.WtUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *客户端 前端控制器
 * </p>
 *
 * @author eric.zhang
 * @since 2018-10-08
 */
@RestController
public class WtCoreClientController extends WtBaseController implements WtCoreClientService {

    @Autowired
    WtDictionaryItemService wtDictionaryItemService;

    @Autowired
    WtUserService wtUserService;

    @Override
    public WtBaseResponse<WtDictionaryItemEntity> getDictByType(@RequestBody WtDictListReqeust reqeust) {
        this.volidate(reqeust);
        return new WtBaseResponse(wtDictionaryItemService.listByTypeId(reqeust.getTypeId()));
    }

    @Override
    public WtBaseResponse<WtUserEntity> getUserInfo(@RequestBody WtPrimaryKeyReqeust<Long> reqeust) {
        this.volidate(reqeust);
        WtUserEntity wtUserEntity = wtUserService.getById(reqeust.getId());
        wtUserEntity.setPassword("");
        return new WtBaseResponse<WtUserEntity>(wtUserEntity);
    }

}
